<!--
 * @Author: wangming
 * @Date: 2021-05-29 15:44:34
 * @LastEditors: wangming
 * @LastEditTime: 2022-02-07 16:54:19
 * @Description: file content   
-->
<template>
  <div>
    <el-form-item
      label="默认值"
      v-if="value.__config.matchRule == 'SECTION_MATCH'"
    >
      <!-- <el-input-number
        v-model="value.defaultValue[0]"
        controls-position="right"
        :min="value.__config.min"
        :max="value.__config.max"
      ></el-input-number> -->
      <xInput
        placeholder="请输入默认数字"
        size="small"
        style="width: 100%"
        :value="value.defaultValue[0]"
        :limitNumber="value.__config.limitNumber"
        @input="outInput($event, 0)"
      ></xInput>
      --
      <!-- <el-input-number
        v-model="value.defaultValue[1]"
        controls-position="right"
        :min="value.__config.min"
        :max="value.__config.max"
      ></el-input-number> -->
      <xInput
        placeholder="请输入默认数字"
        size="small"
        style="width: 100%"
        :value="value.defaultValue[1]"
        :limitNumber="value.__config.limitNumber"
        @input="outInput($event, 1)"
      ></xInput>
    </el-form-item>
    <el-form-item label="默认值" v-else>
      <!-- <el-input-number
        v-model="value.defaultValue[0]"
        controls-position="right"
        :min="value.__config.min"
        :max="value.__config.max"
      ></el-input-number> -->
      <xInput
        placeholder="请输入默认数字"
        size="small"
        style="width: 100%"
        :value="value.defaultValue[0]"
        :limitNumber="value.__config.limitNumber"
        @input="outInput($event, 0)"
      ></xInput>
    </el-form-item>
  </div>
</template>

<script>
import basicmixins from "../../basicmixins";
import xInput from "@/components/xInput/index.js";
export default {
  components: {
    xInput,
  },
  mixins: [basicmixins],
  data() {
    return {};
  },
  mounted() {},
  watch: {},
  methods: {
    outInput(v, index) {
      if (v !== 0 && !v) {
        this.value.defaultValue.splice(index, 1, null);
      } else {
        this.value.defaultValue.splice(index, 1, Number(v));
        // let finalValue = v;
        // Number(v) < this.value.__config.min &&
        //   (finalValue = this.value.__config.min);
        // Number(v) > this.value.__config.max &&
        //   (finalValue = this.value.__config.max);
        // if (
        //   Number(v) >= this.value.__config.min &&
        //   Number(v) <= this.value.__config.max
        // ) {
        //   if (index == 0) {
        //     this.value.defaultValue[1] !== null &&
        //       Number(v) > this.value.defaultValue[1] &&
        //       finalValue == this.value.defaultValue[1];
        //   }
        //   if (index == 1) {
        //     this.value.defaultValue[0] !== null &&
        //       Number(v) < this.value.defaultValue[0] &&
        //       finalValue == this.value.defaultValue[0];
        //   }
        // }
        // this.value.defaultValue.splice(index, 1, Number(finalValue));
      }
    },
  },
};
</script>

<style lang="scss" scoped></style>
